import time

from selenium import webdriver

from Lib.zcm.common.ui.PageElement import PageElement
from Lib.zcm.fish.Select import Select
from ..common.ui.Selector import Selector
import pytest

def test_select_single():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/select/index.html")
    time.sleep(2)
    try:
        select1 = Select(browser, 'select1', Selector.ID)
        print(select1.getValue())
        select1.setValue("Option 8")
        select2 = Select(browser, 'select2', Selector.ID)
        select2.setValue("option 8")
    finally:
        time.sleep(2)
        browser.close()


def test_select_mutil():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/select/index.html")
    time.sleep(2)
    try:
        el = PageElement(browser, "multiple.html", Selector.ID)
        el.click()
        select = Select(browser, 'select1', Selector.ID)
        select.setValue("Option 8", "Option 7")
    finally:
        time.sleep(2)
        browser.close()

if __name__ == '__main__':
    pytest.main(['-s', 'Tree_test.py'])
